home *** CD-ROM | disk | FTP | other *** search
/ Wired for Sound Pro / Wired for Sound Pro CD (Aristosoft, Inc.) (1993).ISO / wfscdset / cuiwfsp / dlgprocs.c < prev    next >
C/C++ Source or Header  |  1993-11-01  |  37KB  |  1,580 lines

  1. /***************************************************************************/
  2. /*********************  Sample Dialog Procedures  **************************/
  3. /***************************************************************************/
  4.  
  5. #include "cui.h"
  6. #include "dialogs.h"
  7. #include <stdlib.h>
  8. #include <direct.h>
  9. #include <ctype.h>
  10.  
  11.  
  12. #define iszBMax    11
  13. #define INT_MAX    32767     /* maximum (signed) int value */
  14. #define cbSymBuf   1024
  15. #define cbNameMax  52
  16.  
  17.  
  18. LPSTR  _sz = NULL;
  19.  
  20. #define  FSingleByteCharSz(sz)  ((BOOL)(((_sz = (sz)) != NULL) \
  21.                                     && AnsiNext((LPSTR)(_sz)) == _sz + 1))
  22.  
  23. int   FAR PASCAL LibMain(HANDLE, WORD, WORD, LPSTR);
  24. int   FAR PASCAL WEP (int);
  25. LPSTR FAR PASCAL SzLastChar(LPSTR);
  26. LPSTR FAR PASCAL SzDlgEvent(WORD);
  27. int   FAR PASCAL AsciiToInt(LPSTR);
  28. LPSTR FAR PASCAL IntToAscii(int, LPSTR);
  29.  
  30.  
  31. int FAR PASCAL RmDir(LPSTR lpszDir) {
  32.     static char szDir[128];
  33.  
  34.     lstrcpy(szDir, lpszDir);
  35.     return _rmdir(szDir);
  36. }
  37.  
  38.  
  39. /*
  40. **    Purpose:
  41. **        CheckBox Dialog procedure for templates with one to ten checkbox
  42. **        controls.
  43. **
  44. **    Controls Recognized:
  45. **        Checkbox   - IDC_B1 to IDC_B10 (sequential)
  46. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  47. **
  48. **    Initialization Symbols:
  49. **        "CheckItemsIn" - list of "ON" and "OFF" string items for setting
  50. **            the intial state of the checkbox controls, evaluated in
  51. **            sequence ("ON" for checked, "OFF" for unchecked).  If there
  52. **            are more controls than items, extra controls are left unchecked.
  53. **            If there are fewer items than controls, extra items are ignored.
  54. **        "OptionsGreyed" - list of (one-based) indexes of checkboxes to be
  55. **            initialized as disabled.  Indexes not in the list will be
  56. **            left enabled.
  57. **
  58. **    Termination Symbols:
  59. **        "CheckItemsOut" - list of same format as "CheckItemsIn" representing
  60. **            state of checkbox controls upon return.
  61. **        "DLGEVENT" - one of the following, according to control event:
  62. **                event     value
  63. **                -------   -------
  64. **                IDC_B     "BACK"
  65. **                IDC_C     "CONTINUE"
  66. **                IDC_X     "EXIT"
  67. **                IDCANCEL  "CANCEL"
  68. **
  69. **    Note:
  70. **        Pushbutton IDC_H will open the related Help dialog, if any.
  71. **
  72. *****************************************************************************/
  73. BOOL FAR PASCAL FCheckDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  74. {
  75.     WORD idc, cb, i, cItems;
  76.     char szSymBuf[cbSymBuf];
  77.  
  78.     switch (wMsg)
  79.         {
  80.     case WM_INITDIALOG:
  81.         cItems = UsGetListLength("CheckItemsIn");
  82.         idc = IDC_B1;
  83.         for (i = 1; i <= cItems; ++i)
  84.             {
  85.             WORD wCheck = 0;
  86.  
  87.             cb = CbGetListItem("CheckItemsIn", i, szSymBuf, cbSymBuf);
  88.             Assert(cb < cbSymBuf);
  89.             if (lstrcmp(szSymBuf, "ON") == 0)
  90.                 wCheck = 1;
  91.             CheckDlgButton(hdlg, idc++, wCheck);
  92.             }
  93.  
  94.         cItems = UsGetListLength("OptionsGreyed");
  95.         idc = IDC_B1;
  96.         for (i = 1; i <= cItems; ++i)
  97.             {
  98.             int iOpt;
  99.  
  100.             cb = CbGetListItem("OptionsGreyed", i, szSymBuf, cbSymBuf);
  101.             Assert(cb < cbSymBuf);
  102.             iOpt  = AsciiToInt((LPSTR)szSymBuf);
  103.             if (iOpt > 0
  104.                     && iOpt <= 10)
  105.                 EnableWindow(GetDlgItem(hdlg, IDC_B0 + iOpt), 0);
  106.             else if (*szSymBuf != '\0')
  107.                 Assert(fFalse);
  108.             }
  109.         return(fTrue);
  110.  
  111.     case STF_REINITDIALOG:
  112.     case STF_ACTIVATEAPP:
  113.         return(fTrue);
  114.  
  115.     case WM_COMMAND:
  116.         switch (wParam)
  117.             {
  118.         case IDC_B1:
  119.         case IDC_B2:
  120.         case IDC_B3:
  121.         case IDC_B4:
  122.         case IDC_B5:
  123.         case IDC_B6:
  124.         case IDC_B7:
  125.         case IDC_B8:
  126.         case IDC_B9:
  127.         case IDC_B10:
  128.             CheckDlgButton(hdlg, wParam,
  129.                     (WORD)!IsDlgButtonChecked(hdlg, wParam));
  130.             break;
  131.  
  132.         case IDC_H:
  133.             HdlgShowHelp();
  134.             return(fTrue);
  135.  
  136.         case IDC_B:
  137.         case IDC_C:
  138.         case IDC_X:
  139.         case IDCANCEL:
  140.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  141.                 {
  142.                 DestroyWindow(GetParent(hdlg));
  143.                 return(fTrue);
  144.                 }
  145.  
  146.             FRemoveSymbol("CheckItemsOut");
  147.             for (idc = IDC_B1; GetDlgItem(hdlg, idc); idc++)
  148.                 if (!FAddListItem("CheckItemsOut",
  149.                         IsDlgButtonChecked(hdlg, idc) ? "ON" : "OFF"))
  150.                     {
  151.                     DestroyWindow(GetParent(hdlg));
  152.                     return(fFalse);
  153.                     }
  154.             Assert((unsigned)(idc-IDC_B1+1) <= iszBMax);
  155.  
  156.             ReactivateSetupScript();
  157.             break;
  158.             }
  159.         break;
  160.         }
  161.  
  162.     return(fFalse);
  163. }
  164.  
  165.  
  166.  
  167. /*
  168. **    Purpose:
  169. **        Custom Install Dialog procedure for templates with one to ten custom
  170. **        options each consisting of at least one checkbox with an optional
  171. **        sub-option pushbutton or status string.  The dialog also supports
  172. **        an install path set button, display of the current install path, and
  173. **        display of the current disk space status.
  174. **
  175. **    Controls Recognized:
  176. **        Checkbox   - IDC_B1 to IDC_B10
  177. **            with optionaly assocated buttons or text:
  178. **            Pushbutton - IDC_SP1 to IDC_SP10
  179. **            Text       - IDC_STATUS1 to IDC_STATUS10
  180. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_P, IDC_X
  181. **        Text       - IDC_TEXT1 through IDC_TEXT7
  182. **
  183. **    Initialization Symbols:
  184. **        "CheckItemsState" - list of "ON" and "OFF" string items for setting
  185. **            the intial state of the checkbox controls, evaluated in
  186. **            sequence ("ON" for checked, "OFF" for unchecked).  If there
  187. **            are more controls than items, extra controls are left unchecked.
  188. **            If there are fewer items than controls, extra items are ignored.
  189. **        "StatusItemsText" - list of strings to initialize status text items
  190. **            associated with checkboxes.
  191. **        "DriveStatusText" - list of seven strings to initialize drive status
  192. **            text items (IDC_TEXT1-7) in the following sequence:
  193. **                dst_drive, dst_space_need, dst_space_free,
  194. **                win_drive, win_space_need, win_space_free,
  195. **                dst_path
  196. **            If any of the "win_" items is an empty string, its label
  197. **            text will be made non-visible.
  198. **
  199. **    Termination Symbols:
  200. **        "CheckItemsState" - state of checkbox items (same format as above).
  201. **        "DLGEVENT" - one of the following, depending on event:
  202. **                event                value
  203. **                ----------           ----------
  204. **                IDC_B                "BACK"
  205. **                IDC_C                "CONTINUE"
  206. **                IDC_P                "PATH"
  207. **                IDC_X                "EXIT"
  208. **                IDC_B1  to IDC_B10   "CHK1" to "CHK10"
  209. **                IDC_SP1 to IDC_SP10  "BTN1" to "BTN10"
  210. **                IDCANCEL             "CANCEL"
  211. **                STF_ACTIVATEAPP      "REACTIVATE"
  212. **
  213. **    Note:
  214. **        Pushbutton IDC_H will open the related Help dialog, if any.
  215. **
  216. *****************************************************************************/
  217. BOOL FAR PASCAL FCustInstDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  218. {
  219.     char  rgchChk[10];
  220.     char  rgchBtn[10];
  221.     WORD  idc;
  222.     WORD  cItems;
  223.     WORD  i, cb;
  224.     char  szSymBuf[cbSymBuf];
  225.     LPSTR szEvent;
  226.  
  227.     switch (wMsg)
  228.         {
  229.     case STF_ACTIVATEAPP:
  230.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  231.             {
  232.             DestroyWindow(GetParent(hdlg));
  233.             return(fTrue);
  234.             }
  235.         ReactivateSetupScript();
  236.         return(fTrue);
  237.  
  238.     case STF_REINITDIALOG:
  239.     case WM_INITDIALOG:
  240.         cItems = UsGetListLength("CheckItemsState");
  241.         idc = IDC_B1;
  242.         for (i = 1; i <= cItems; ++i)
  243.             {
  244.             WORD wCheck = 0;
  245.  
  246.             cb = CbGetListItem("CheckItemsState", i, szSymBuf, cbSymBuf);
  247.             Assert(cb < cbSymBuf);
  248.             if (lstrcmp(szSymBuf, "ON") == 0)
  249.                 wCheck = 1;
  250.             CheckDlgButton(hdlg, idc++, wCheck);
  251.             }
  252.  
  253.         cItems = UsGetListLength("StatusItemsText");
  254.         idc = IDC_STATUS1;
  255.         for (i = 1; i <= cItems; ++i)
  256.             {
  257.             WORD wCheck = 0;
  258.  
  259.             cb = CbGetListItem("StatusItemsText", i, szSymBuf, cbSymBuf);
  260.             Assert(cb < cbSymBuf);
  261.             SetDlgItemText(hdlg, idc++, szSymBuf);
  262.             }
  263.  
  264.         cItems = UsGetListLength("DriveStatusText");
  265.         idc = IDC_TEXT1;
  266.         for (i = 1; i <= cItems; ++i)
  267.             {
  268.             WORD wCheck = 0;
  269.  
  270.             cb = CbGetListItem("DriveStatusText", i, szSymBuf, cbSymBuf);
  271.             Assert(cb < cbSymBuf);
  272.             SetDlgItemText(hdlg, idc++, szSymBuf);
  273.             if (i >= 4
  274.                     && i <= 6)
  275.                 {
  276.                 if (*szSymBuf == '\0')
  277.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_HIDE);
  278.                 else
  279.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_SHOWNOACTIVATE);
  280.                 }
  281.             }
  282.  
  283.         return(fTrue);
  284.  
  285.     case WM_COMMAND:
  286.         switch(wParam)
  287.             {
  288.         default:
  289.             szEvent = (LPSTR)NULL;
  290.             break;
  291.  
  292.         case IDC_B1:
  293.         case IDC_B2:
  294.         case IDC_B3:
  295.         case IDC_B4:
  296.         case IDC_B5:
  297.         case IDC_B6:
  298.         case IDC_B7:
  299.         case IDC_B8:
  300.         case IDC_B9:
  301.         case IDC_B10:
  302.             lstrcpy((LPSTR)rgchChk, "CHK");
  303.             IntToAscii((int)(wParam-IDC_B1+1), (LPSTR)(&rgchChk[3]));
  304.             szEvent = (LPSTR)rgchChk;
  305.             break;
  306.  
  307.         case IDC_SP1:
  308.         case IDC_SP2:
  309.         case IDC_SP3:
  310.         case IDC_SP4:
  311.         case IDC_SP5:
  312.         case IDC_SP6:
  313.         case IDC_SP7:
  314.         case IDC_SP8:
  315.         case IDC_SP9:
  316.         case IDC_SP10:
  317.             lstrcpy((LPSTR)rgchBtn, "BTN");
  318.             IntToAscii((int)(wParam-IDC_SP1+1), (LPSTR)(&rgchBtn[3]));
  319.             szEvent = (LPSTR)rgchBtn;
  320.             break;
  321.  
  322.         case IDOK:
  323.             wParam = IDC_C;
  324.         case IDC_B:
  325.         case IDC_C:
  326.         case IDC_X:
  327.         case IDCANCEL:
  328.             szEvent = SzDlgEvent(wParam);
  329.             Assert(szEvent != NULL);
  330.             break;
  331.  
  332.         case IDC_P:
  333.             szEvent = "PATH";
  334.             break;
  335.  
  336.         case IDC_H:
  337.             HdlgShowHelp();
  338.             return(fTrue);
  339.  
  340.             }
  341.  
  342.         if (szEvent == (LPSTR)NULL)
  343.             break;
  344.  
  345.         FRemoveSymbol("CheckItemsState");
  346.         for (idc = IDC_B1; GetDlgItem(hdlg, idc); idc++)
  347.             if (!FAddListItem("CheckItemsState",
  348.                     IsDlgButtonChecked(hdlg, idc) ? "ON" : "OFF"))
  349.                 {
  350.                 DestroyWindow(GetParent(hdlg));
  351.                 return(fFalse);
  352.                 }
  353.         Assert((unsigned)(idc-IDC_B1+1) <= iszBMax);
  354.  
  355.         if (szEvent != (LPSTR)NULL)
  356.             if (!FSetSymbolValue("DLGEVENT", szEvent))
  357.                 {
  358.                 DestroyWindow(GetParent(hdlg));
  359.                 return(fTrue);
  360.                 }
  361.  
  362.         ReactivateSetupScript();
  363.         break;
  364.         }
  365.  
  366.     return(fFalse);
  367. }
  368.  
  369.  
  370.  
  371. /*
  372. **    Purpose:
  373. **        Edit Dialog procedure for templates with one Edit control.
  374. **        (Limits the input string length to cbFullPathMax characters.)
  375. **
  376. **    Controls Recognized:
  377. **        Edit       - IDC_EDIT
  378. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  379. **
  380. **    Initialization Symbols:
  381. **        "EditTextIn" - initial text for IDC_EDIT edit control.
  382. **        "EditFocus"  - position of intial focus for text string:
  383. **                "END" (default), "ALL", or "START"
  384. **
  385. **    Termination Symbols:
  386. **        "EditTextOut" - text in the IDC_EDIT edit control upon termination.
  387. **        "DLGEVENT"    - one of the following, depending on event:
  388. **                event                value
  389. **                ----------           ----------
  390. **                IDC_B                "BACK"
  391. **                IDC_C                "CONTINUE"
  392. **                IDC_X                "EXIT"
  393. **                IDCANCEL             "CANCEL"
  394. **                STF_ACTIVATEAPP      "REACTIVATE"
  395. **
  396. **    Note:
  397. **        Pushbutton IDC_H will open the related Help dialog, if any.
  398. **
  399. *****************************************************************************/
  400. BOOL FAR PASCAL FEditDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  401. {
  402.     static WORD wSelStart = 0;
  403.     static WORD wSelEnd   = 0;
  404.     char  rgchText[cbFullPathMax + 1];
  405.     WORD  cbLen;
  406.     WORD  cb;
  407.     char  szSymBuf[cbFullPathMax + 1];
  408.  
  409.     switch (wMsg)
  410.         {
  411.     case STF_ACTIVATEAPP:
  412.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  413.             {
  414.             DestroyWindow(GetParent(hdlg));
  415.             return(fTrue);
  416.             }
  417.         ReactivateSetupScript();
  418.         return(fTrue);
  419.  
  420.     case WM_INITDIALOG:
  421.         cb = CbGetSymbolValue("EditTextIn", szSymBuf, cbFullPathMax + 1);
  422.         Assert(cb < cbFullPathMax + 1);
  423.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_LIMITTEXT, cbFullPathMax, 0L);
  424.         SetDlgItemText(hdlg, IDC_EDIT, (LPSTR)szSymBuf);
  425.  
  426.         cbLen = lstrlen(szSymBuf);
  427.         cb = CbGetSymbolValue("EditFocus", szSymBuf, cbFullPathMax + 1);
  428.         Assert(cb < cbFullPathMax + 1);
  429.  
  430.         if (lstrcmp(szSymBuf, "ALL") == 0)
  431.             {
  432.             wSelStart = 0;
  433.             wSelEnd   = INT_MAX;
  434.             }
  435.         else if (lstrcmp(szSymBuf, "START") == 0)
  436.             {
  437.             wSelStart = 0;
  438.             wSelEnd   = 0;
  439.             }
  440.         else       /* default == END */
  441.             {
  442.             wSelStart = (WORD)cbLen;
  443.             wSelEnd   = (WORD)cbLen;
  444.             }
  445.         return(fTrue);
  446.  
  447.     case STF_REINITDIALOG:
  448.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0, MAKELONG(256, 256));
  449.         SetFocus(GetDlgItem(hdlg, IDC_EDIT));
  450.         return(fTrue);
  451.  
  452.     case WM_COMMAND:
  453.         switch(wParam)
  454.             {
  455.         case IDC_EDIT:
  456.             if (HIWORD(lParam) == EN_SETFOCUS)
  457.                 SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0,
  458.                         MAKELONG(wSelStart, wSelEnd));
  459.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  460.                 {
  461.                 LONG  l = SendDlgItemMessage(hdlg, IDC_EDIT, EM_GETSEL, 0, 0L);
  462.  
  463.                 wSelStart = LOWORD(l);
  464.                 wSelEnd   = HIWORD(l);
  465.                 }
  466.             break;
  467.  
  468.         case IDC_H:
  469.             HdlgShowHelp();
  470.             return(fTrue);
  471.  
  472.         case IDC_B:
  473.         case IDC_C:
  474.         case IDC_X:
  475.         case IDCANCEL:
  476.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  477.                 {
  478.                 DestroyWindow(GetParent(hdlg));
  479.                 return(fTrue);
  480.                 }
  481.             SendDlgItemMessage(hdlg, IDC_EDIT, (WORD)WM_GETTEXT,
  482.                     cbFullPathMax + 1, (LONG)((LPSTR)rgchText));
  483.             if (!FSetSymbolValue("EditTextOut", rgchText))
  484.                 {
  485.                 DestroyWindow(GetParent(hdlg));
  486.                 return(fTrue);
  487.                 }
  488.             ReactivateSetupScript();
  489.             break;
  490.             }
  491.         break;
  492.         }
  493.  
  494.     return(fFalse);
  495. }
  496.  
  497.  
  498.  
  499. /*
  500. **    Purpose:
  501. **        Help Dialog procedure.
  502. **
  503. **    Controls Recognized:
  504. **        Pushbutton - IDC_X.
  505. **
  506. **    Initialization Symbols:
  507. **        none.
  508. **
  509. **    Termination Symbols:
  510. **        none. (Handles IDC_X and IDCANCEL events by calling FCloseHelp.)
  511. **
  512. **    Note:
  513. **        This dialog proc is for Help dialogs ONLY (szHelpProc$ parameter
  514. **        of UIStartDlg) and CANNOT be used as the szDlgProc$ parameter
  515. **        of the UIStartDlg MSSetup script function.
  516. **
  517. *****************************************************************************/
  518. BOOL FAR PASCAL FHelpDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  519. {
  520.     switch (wMsg)
  521.         {
  522.     case WM_INITDIALOG:
  523.         return(fTrue);
  524.  
  525.     case STF_REINITDIALOG:
  526.         return(fTrue);
  527.  
  528.     case STF_ACTIVATEAPP:
  529.         /* Help dlg should not be on the dlg stack
  530.         ** and should never get this message.
  531.         */
  532.         Assert(fFalse);
  533.         return(fTrue);
  534.  
  535.     case WM_COMMAND:
  536.         if (wParam != IDC_X
  537.             && wParam != IDCANCEL)
  538.             break;
  539.         FCloseHelp();
  540.         return(fTrue);
  541.  
  542.         }
  543.     return(fFalse);
  544. }
  545.  
  546.  
  547.  
  548. /*
  549. **    Purpose:
  550. **        Information Dialog procedure.
  551. **
  552. **    Controls Recognized:
  553. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  554. **
  555. **    Initialization Symbols:
  556. **        none.
  557. **
  558. **    Termination Symbols:
  559. **        "DLGEVENT" - one of the following, according to control event:
  560. **                event     value
  561. **                -------   -------
  562. **                IDC_B     "BACK"
  563. **                IDC_C     "CONTINUE"
  564. **                IDC_X     "EXIT"
  565. **                IDCANCEL  "CANCEL"
  566. **
  567. **    Note:
  568. **        Pushbutton IDC_H will open the related Help dialog, if any.
  569. **
  570. *****************************************************************************/
  571. BOOL FAR PASCAL FInfoDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  572. {
  573.     switch (wMsg)
  574.         {
  575.     case WM_INITDIALOG:
  576.         return(fTrue);
  577.  
  578.     case STF_REINITDIALOG:
  579.     case STF_ACTIVATEAPP:
  580.         return(fTrue);
  581.  
  582.     case WM_COMMAND:
  583.         switch (wParam)
  584.             {
  585.         case IDC_H:
  586.             HdlgShowHelp();
  587.             return(fTrue);
  588.  
  589.         case IDC_B:
  590.         case IDC_C:
  591.         case IDC_I:
  592.         case IDC_T:
  593.         case IDC_Y:
  594.         case IDC_N:
  595.         case IDC_X:
  596.         case IDCANCEL:
  597.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  598.                 {
  599.                 DestroyWindow(GetParent(hdlg));
  600.                 return(fTrue);
  601.                 }
  602.             ReactivateSetupScript();
  603.             break;
  604.             }
  605.         break;
  606.         }
  607.  
  608.     return(fFalse);
  609. }
  610.  
  611.  
  612.  
  613. /*
  614. **    Purpose:
  615. **        Information Dialog procedure, without "Exit" button.
  616. **
  617. **    Controls Recognized:
  618. **        Pushbutton - IDC_B, IDC_C, IDC_H
  619. **
  620. **    Initialization Symbols:
  621. **        none.
  622. **
  623. **    Termination Symbols:
  624. **        "DLGEVENT" - one of the following, depending on event:
  625. **                event                value
  626. **                ----------           ----------
  627. **                IDC_B                "BACK"
  628. **                IDC_C                "CONTINUE"
  629. **                IDCANCEL             "CANCEL"
  630. **                STF_ACTIVATEAPP      "REACTIVATE"
  631. **
  632. **    Note:
  633. **        Pushbutton IDC_H will open the related Help dialog, if any.
  634. **
  635. *****************************************************************************/
  636. BOOL FAR PASCAL FInfo0DlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  637. {
  638.     switch (wMsg)
  639.         {
  640.     case WM_INITDIALOG:
  641.         return(fTrue);
  642.  
  643.     case STF_REINITDIALOG:
  644.         return(fTrue);
  645.  
  646.     case STF_ACTIVATEAPP:
  647.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  648.             {
  649.             DestroyWindow(GetParent(hdlg));
  650.             return(fTrue);
  651.             }
  652.         ReactivateSetupScript();
  653.         return(fTrue);
  654.  
  655.     case WM_COMMAND:
  656.         switch (wParam)
  657.             {
  658.         case IDC_H:
  659.             HdlgShowHelp();
  660.             return(fTrue);
  661.  
  662.         case IDC_B:
  663.         case IDC_C:
  664.         case IDCANCEL:
  665.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  666.                 {
  667.                 DestroyWindow(GetParent(hdlg));
  668.                 return(fTrue);
  669.                 }
  670.             ReactivateSetupScript();
  671.             break;
  672.             }
  673.         break;
  674.         }
  675.  
  676.     return(fFalse);
  677. }
  678.  
  679.  
  680.  
  681. /*
  682. **    Purpose:
  683. **        Single Choice Listbox Dialog procedure for templates with exactly one
  684. **        listbox control.
  685. **
  686. **    Controls Recognized:
  687. **        Listbox    - IDC_LIST1
  688. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  689. **
  690. **    Initialization Symbols:
  691. **        "ListItemsIn"  - list of strings to put in the listbox.
  692. **        "ListItemsOut" - simple string (not a list) representing an
  693. **            initial selection in "ListItemsIn".
  694. **
  695. **    Termination Symbols:
  696. **        "ListItemsOut" - selected list item string.
  697. **        "DLGEVENT"     - one of the following, according to control event:
  698. **                event     value
  699. **                -------   -------
  700. **                IDC_B     "BACK"
  701. **                IDC_C     "CONTINUE"
  702. **                IDC_X     "EXIT"
  703. **                IDCANCEL  "CANCEL"
  704. **
  705. **    Note:
  706. **        Pushbutton IDC_H will open the related Help dialog, if any.
  707. **
  708. *****************************************************************************/
  709. BOOL FAR PASCAL FListDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  710. {
  711.     char szListIn[cbSymBuf];
  712.     char szListOut[cbSymBuf];
  713.     WORD iItem;
  714.     WORD cb, i;
  715.     WORD cItems;
  716.  
  717.     switch (wMsg)
  718.         {
  719.     case WM_INITDIALOG:
  720.         cItems = UsGetListLength("ListItemsIn");
  721.         for (i = 1; i <= cItems; ++i)
  722.             {
  723.             cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  724.             Assert(cb < cbSymBuf);
  725.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_ADDSTRING, 0,
  726.                     (LONG)(LPSTR)szListIn);
  727.             }
  728.  
  729.         cb = CbGetSymbolValue("ListItemsOut", szListOut, cbSymBuf);
  730.         Assert(cb < cbSymBuf);
  731.         if (cb == 0)
  732.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETCURSEL, (WORD)-1, 0L);
  733.         else
  734.             {
  735.             for (i = 1, iItem = 0; i <= cItems; ++i, ++iItem)
  736.                 {
  737.                 cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  738.                 Assert(cb < cbSymBuf);
  739.                 if (lstrcmp(szListOut, szListIn) == 0)
  740.                     {
  741.                     SendDlgItemMessage(hdlg,IDC_LIST1,LB_SETCURSEL,iItem,0L);
  742.                     break;
  743.                     }
  744.                 }
  745.             }
  746.  
  747.         /* Note: Depends on number of lines in list box.
  748.         */
  749.         if (iItem < 4)
  750.             iItem = 0;
  751.         SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETTOPINDEX, iItem, 0L);
  752.  
  753.         return(fTrue);
  754.  
  755.     case STF_REINITDIALOG:
  756.     case STF_ACTIVATEAPP:
  757.         return(fTrue);
  758.  
  759.     case WM_COMMAND:
  760.         switch(wParam)
  761.             {
  762.         case IDC_H:
  763.             HdlgShowHelp();
  764.             return(fTrue);
  765.  
  766.         case IDC_LIST1:
  767.             if (HIWORD(lParam) != LBN_DBLCLK)
  768.                 break;
  769.             wParam = IDC_C;
  770.         case IDC_B:
  771.         case IDC_C:
  772.         case IDC_X:
  773.         case IDCANCEL:
  774.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  775.                 {
  776.                 DestroyWindow(GetParent(hdlg));
  777.                 return(fTrue);
  778.                 }
  779.  
  780.             if ((iItem = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCURSEL,
  781.                         0, 0L)) == LB_ERR
  782.                     || (cb = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1,
  783.                             LB_GETTEXTLEN, iItem, 0L)) == LB_ERR)
  784.                 *szListOut = '\0';
  785.             else
  786.                 {
  787.                 Assert(cb <= cbSymBuf);
  788.                 SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETTEXT, iItem,
  789.                         (LONG)(LPSTR)szListOut);
  790.                 }
  791.             if (!FSetSymbolValue("ListItemsOut", szListOut))
  792.                 {
  793.                 DestroyWindow(GetParent(hdlg));
  794.                 return(fTrue);
  795.                 }
  796.  
  797.             ReactivateSetupScript();
  798.             break;
  799.             }
  800.         break;
  801.  
  802.         }
  803.  
  804.     return(fFalse);
  805. }
  806.  
  807.  
  808.  
  809. /*
  810. **    Purpose:
  811. **        Modeless Dialog procedure.
  812. **
  813. **    Controls Recognized:
  814. **        none.
  815. **
  816. **    Initialization Symbols:
  817. **        none.
  818. **
  819. **    Termination Symbols:
  820. **        none.
  821. **
  822. **    Note:
  823. **        This dialog procedure is REQUIRED with use of any Billboard
  824. **        MSSetup script functions.
  825. **
  826. *****************************************************************************/
  827. BOOL FAR PASCAL FModelessDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  828. {
  829.     switch (wMsg)
  830.         {
  831.     case WM_INITDIALOG:
  832.         ReactivateSetupScript();
  833.         return(fTrue);
  834.  
  835.     case STF_REINITDIALOG:
  836.     case STF_ACTIVATEAPP:
  837.         return(fTrue);
  838.  
  839.     case WM_CLOSE:
  840.     case WM_COMMAND:
  841.         Assert(fFalse);
  842.         break;
  843.         }
  844.  
  845.     return(fFalse);
  846. }
  847.  
  848.  
  849.  
  850. /*
  851. **    Purpose:
  852. **        Multiple Choice Listbox Dialog procedure for templates with
  853. **        exactly one listbox control.
  854. **
  855. **    Controls Recognized:
  856. **        Listbox    - IDC_LIST1
  857. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_L, IDC_S, IDC_X
  858. **
  859. **    Initialization Symbols:
  860. **        "ListItemsIn"  - list of strings to put in the listbox.
  861. **        "ListItemsOut" - list of strings representing initial
  862. **            selections in "ListItemsIn".
  863. **
  864. **    Termination Symbols:
  865. **        "ListItemsOut" - list of items selected (if any).
  866. **        "DLGEVENT"     - one of the following, according to control event:
  867. **                event     value
  868. **                -------   -------
  869. **                IDC_B     "BACK"
  870. **                IDC_C     "CONTINUE"
  871. **                IDC_X     "EXIT"
  872. **                IDCANCEL  "CANCEL"
  873. **
  874. **    Note:
  875. **        Pushbutton IDC_H will open the related Help dialog, if any.
  876. **        Pushbuttons IDC_L and IDC_S are for "clear all" and "select all"
  877. **        respectively.
  878. **
  879. *****************************************************************************/
  880. BOOL FAR PASCAL FMultiDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  881. {
  882.     WORD i, j, nCount;
  883.     char szListIn[cbSymBuf];
  884.     char szListOut[cbSymBuf];
  885.     WORD iItem, iItemTop;
  886.     WORD cb;
  887.     WORD cItemsIn, cItemsOut;
  888.  
  889.     switch (wMsg)
  890.         {
  891.     case WM_INITDIALOG:
  892.         cItemsIn = UsGetListLength("ListItemsIn");
  893.         nCount = 0;
  894.         for (i = 1; i <= cItemsIn; ++i)
  895.             {
  896.             cb = CbGetListItem("ListItemsIn", i, szListIn, cbSymBuf);
  897.             Assert(cb < cbSymBuf);
  898.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_ADDSTRING, 0,
  899.                     (LONG)(LPSTR)szListIn);
  900.             nCount++;
  901.             }
  902.         Assert(nCount == (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT,
  903.                 0, 0L));
  904.  
  905.         cItemsOut = UsGetListLength("ListItemsOut");
  906.         for (i = 1, iItemTop = 0; i <= cItemsOut; ++i, ++iItemTop)
  907.             {
  908.             cb = CbGetListItem("ListItemsOut", i, szListOut, cbSymBuf);
  909.             Assert(cb < cbSymBuf);
  910.             for (j = 1, iItem = 0; j <= cItemsIn; ++j, ++iItem)
  911.                 {
  912.                 cb = CbGetListItem("ListItemsIn", j, szListIn, cbSymBuf);
  913.                 Assert(cb < cbSymBuf);
  914.                 if (lstrcmp(szListOut, szListIn) == 0)
  915.                     {
  916.                     SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETSEL, 1,
  917.                             MAKELONG(iItem, 0));
  918.                     if (iItemTop == 0
  919.                             || (WORD)iItem < iItemTop)
  920.                         iItemTop = (WORD)iItem;
  921.                     break;
  922.                     }
  923.                 }
  924.             }
  925.  
  926.         /* Note: Depends on number of lines in list box.
  927.         */
  928.         if (iItemTop < 4)
  929.             iItemTop = 0;
  930.         SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETTOPINDEX, iItemTop, 0L);
  931.  
  932.         return(fTrue);
  933.  
  934.     case STF_REINITDIALOG:
  935.     case STF_ACTIVATEAPP:
  936.         return(fTrue);
  937.  
  938.     case WM_COMMAND:
  939.         switch(wParam)
  940.             {
  941.         case IDC_S:
  942.         case IDC_L:
  943.             SendDlgItemMessage(hdlg, IDC_LIST1, LB_SETSEL, (wParam == IDC_S),
  944.                     -1L);
  945.             break;
  946.  
  947.         case IDC_H:
  948.             HdlgShowHelp();
  949.             return(fTrue);
  950.  
  951.         case IDC_B:
  952.         case IDC_C:
  953.         case IDC_X:
  954.         case IDCANCEL:
  955.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  956.                 {
  957.                 DestroyWindow(GetParent(hdlg));
  958.                 return(fTrue);
  959.                 }
  960.  
  961.             /* Note: Could be faster to use LB_GETSELITEMS here.
  962.             */
  963.             nCount = (WORD)SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETCOUNT, 0,
  964.                     0L);
  965.  
  966.             FRemoveSymbol("ListItemsOut");
  967.             for (i = 0; i < nCount; i++)
  968.                 {
  969.                 if (SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETSEL, (WORD)i, 0L))
  970.                     {
  971.                     SendDlgItemMessage(hdlg, IDC_LIST1, LB_GETTEXT, (WORD)i,
  972.                             (LONG)(LPSTR)szListOut);
  973.                     if (!FAddListItem("ListItemsOut", szListOut))
  974.                         {
  975.                         DestroyWindow(GetParent(hdlg));
  976.                         return(fTrue);
  977.                         }
  978.                     }
  979.                 }
  980.  
  981.             ReactivateSetupScript();
  982.             break;
  983.             }
  984.         break;
  985.         }
  986.  
  987.     return(fFalse);
  988. }
  989.  
  990.  
  991.  
  992. /*
  993. **    Purpose:
  994. **        Quit Dialog procedure.
  995. **
  996. **    Controls Recognized:
  997. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  998. **
  999. **    Initialization Symbols:
  1000. **        none.
  1001. **
  1002. **    Termination Symbols:
  1003. **        "DLGEVENT" - one of the following, depending on event:
  1004. **                event                value
  1005. **                ----------           ----------
  1006. **                IDC_B                "BACK"
  1007. **                IDC_C                "CONTINUE"
  1008. **                IDC_X                "EXIT"
  1009. **                IDCANCEL             "CANCEL"
  1010. **                STF_ACTIVATEAPP      "REACTIVATE"
  1011. **
  1012. **    Note:
  1013. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1014. **
  1015. *****************************************************************************/
  1016. BOOL FAR PASCAL FQuitDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1017. {
  1018.     switch (wMsg)
  1019.         {
  1020.     case WM_INITDIALOG:
  1021.         return(fTrue);
  1022.  
  1023.     case STF_REINITDIALOG:
  1024.         return(fTrue);
  1025.  
  1026.     case STF_ACTIVATEAPP:
  1027.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  1028.             {
  1029.             DestroyWindow(GetParent(hdlg));
  1030.             return(fTrue);
  1031.             }
  1032.         ReactivateSetupScript();
  1033.         return(fTrue);
  1034.  
  1035.     case WM_COMMAND:
  1036.         switch(wParam)
  1037.             {
  1038.         case IDC_H:
  1039.             HdlgShowHelp();
  1040.             return(fTrue);
  1041.  
  1042.         case IDC_B:
  1043.         case IDC_C:
  1044.         case IDC_X:
  1045.         case IDCANCEL:
  1046.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1047.                 {
  1048.                 DestroyWindow(GetParent(hdlg));
  1049.                 return(fTrue);
  1050.                 }
  1051.  
  1052.             ReactivateSetupScript();
  1053.             break;
  1054.             }
  1055.         break;
  1056.         }
  1057.     return(fFalse);
  1058. }
  1059.  
  1060.  
  1061.  
  1062. /*
  1063. **    Purpose:
  1064. **        Radio Button Group Dialog procedure for templates with one group
  1065. **        of one to ten radio button controls.
  1066. **
  1067. **    Controls Recognized:
  1068. **        Radio      - IDC_B1 to IDC_B10 (sequential)
  1069. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1070. **
  1071. **    Initialization Symbols:
  1072. **        "RadioDefault" - index (one-based) of radio button to be
  1073. **            initialized as selected (default is "1").
  1074. **        "OptionsGreyed" - list of (one-based) indexes of radio buttons
  1075. **            to be initialized as disabled.  Indexes not in the list will
  1076. **            be left enabled.
  1077. **
  1078. **    Termination Symbols:
  1079. **        "ButtonChecked" - index of currently selected radio button.
  1080. **        "DLGEVENT"      - one of the following, depending on event:
  1081. **                event                value
  1082. **                ----------           ----------
  1083. **                IDC_B                "BACK"
  1084. **                IDC_C                "CONTINUE"
  1085. **                IDC_X                "EXIT"
  1086. **                IDCANCEL             "CANCEL"
  1087. **                STF_ACTIVATEAPP      "REACTIVATE"
  1088. **
  1089. **    Note:
  1090. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1091. **
  1092. *****************************************************************************/
  1093. BOOL FAR PASCAL FRadioDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1094. {
  1095.     char rgchNum[10];
  1096.     int  iButtonChecked;
  1097.     char szSymBuf[cbSymBuf];
  1098.     WORD i, cb, cItems, idc;
  1099.  
  1100.     switch (wMsg)
  1101.         {
  1102.     case STF_ACTIVATEAPP:
  1103.         if (!FSetSymbolValue("DLGEVENT", "REACTIVATE"))
  1104.             {
  1105.             DestroyWindow(GetParent(hdlg));
  1106.             return(fTrue);
  1107.             }
  1108.         ReactivateSetupScript();
  1109.         return(fTrue);
  1110.  
  1111.     case WM_INITDIALOG:
  1112.         cb = CbGetSymbolValue("RadioDefault", szSymBuf, cbSymBuf);
  1113.         Assert(cb < cbSymBuf);
  1114.         if (*szSymBuf != '\0')
  1115.             {
  1116.             iButtonChecked = AsciiToInt((LPSTR)szSymBuf);
  1117.             if (iButtonChecked < 1)
  1118.                 iButtonChecked = 0;
  1119.             if (iButtonChecked > 10)
  1120.                 iButtonChecked = 10;
  1121.             }
  1122.         else
  1123.             iButtonChecked = 1;
  1124.  
  1125.         if (iButtonChecked != 0)
  1126.             SendDlgItemMessage(hdlg, IDC_B0 + iButtonChecked, BM_SETCHECK,1,0L);
  1127.  
  1128.         cItems = UsGetListLength("OptionsGreyed");
  1129.         idc = IDC_B1;
  1130.         for (i = 1; i <= cItems; ++i)
  1131.             {
  1132.             int iOpt;
  1133.  
  1134.             cb = CbGetListItem("OptionsGreyed", i, szSymBuf, cbSymBuf);
  1135.             Assert(cb < cbSymBuf);
  1136.             iOpt  = AsciiToInt((LPSTR)szSymBuf);
  1137.             if (iOpt > 0
  1138.                     && iOpt <= 10
  1139.                     && iOpt != iButtonChecked)
  1140.                 EnableWindow(GetDlgItem(hdlg, IDC_B0 + iOpt), 0);
  1141.             else if (*szSymBuf != '\0')
  1142.                 Assert(fFalse);
  1143.             }
  1144.         return(fTrue);
  1145.  
  1146.     case STF_REINITDIALOG:
  1147.         return(fTrue);
  1148.  
  1149.     case WM_COMMAND:
  1150.         switch (wParam)
  1151.             {
  1152.         case IDC_H:
  1153.             HdlgShowHelp();
  1154.             return(fTrue);
  1155.  
  1156.         case IDC_B1:
  1157.         case IDC_B2:
  1158.         case IDC_B3:
  1159.         case IDC_B4:
  1160.         case IDC_B5:
  1161.         case IDC_B6:
  1162.         case IDC_B7:
  1163.         case IDC_B8:
  1164.         case IDC_B9:
  1165.         case IDC_B10:
  1166.             CheckRadioButton(hdlg, IDC_B1, IDC_B10, wParam);
  1167.             if (HIWORD(lParam) != BN_DOUBLECLICKED)
  1168.                 break;
  1169.             wParam = IDC_C;
  1170.         case IDC_B:
  1171.         case IDC_C:
  1172.         case IDC_X:
  1173.         case IDCANCEL:
  1174.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1175.                 {
  1176.                 DestroyWindow(GetParent(hdlg));
  1177.                 return(fTrue);
  1178.                 }
  1179.  
  1180.             iButtonChecked = 0;
  1181.             for (i = 1; i <= 10; i++)
  1182.                 if (SendDlgItemMessage(hdlg, IDC_B0 + i, BM_GETCHECK, 0, 0L))
  1183.                     {
  1184.                     iButtonChecked = i;
  1185.                     break;
  1186.                     }
  1187.  
  1188.             IntToAscii((int)iButtonChecked, (LPSTR)rgchNum);
  1189.             if (!FSetSymbolValue("ButtonChecked", rgchNum))
  1190.                 {
  1191.                 DestroyWindow(GetParent(hdlg));
  1192.                 return(fTrue);
  1193.                 }
  1194.  
  1195.             ReactivateSetupScript();
  1196.             break;
  1197.             }
  1198.         break;
  1199.         }
  1200.  
  1201.     return(fFalse);
  1202. }
  1203.  
  1204.  
  1205.  
  1206. /*
  1207. **    Purpose:
  1208. **        Get Name and Organization Dialog procedure for templates
  1209. **        with two Edit controls.
  1210. **        (Limits the input string length to cbNameMax characters.)
  1211. **
  1212. **    Controls Recognized:
  1213. **        Edit       - IDC_EDIT, IDC_EDIT2
  1214. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1215. **
  1216. **    Initialization Symbols:
  1217. **        none.
  1218. **
  1219. **    Termination Symbols:
  1220. **        "NameOut" - text in the IDC_EDIT edit control upon termination.
  1221. **        "OrgOut"  - text in the IDC_EDIT2 edit control upon termination.
  1222. **        "DLGEVENT"    - one of the following, depending on event:
  1223. **                event                value
  1224. **                ----------           ----------
  1225. **                IDC_B                "BACK"
  1226. **                IDC_C                "CONTINUE"
  1227. **                IDC_X                "EXIT"
  1228. **                IDCANCEL             "CANCEL"
  1229. **
  1230. **    Note:
  1231. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1232. **
  1233. *****************************************************************************/
  1234. BOOL FAR PASCAL FNameOrgDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1235. {
  1236.     static WORD wSelStart1 = 0;
  1237.     static WORD wSelEnd1   = 0;
  1238.     static WORD wSelStart2 = 0;
  1239.     static WORD wSelEnd2   = 0;
  1240.     char  rgchText[cbNameMax + 1];
  1241.  
  1242.     switch (wMsg)
  1243.         {
  1244.     case WM_INITDIALOG:
  1245.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_LIMITTEXT, cbNameMax, 0L);
  1246.         SetDlgItemText(hdlg, IDC_EDIT, (LPSTR)"");
  1247.  
  1248.         SendDlgItemMessage(hdlg, IDC_EDIT2, EM_LIMITTEXT, cbNameMax, 0L);
  1249.         SetDlgItemText(hdlg, IDC_EDIT2, (LPSTR)"");
  1250.  
  1251.         wSelStart1 = wSelEnd1 = 0;
  1252.         wSelStart2 = wSelEnd2 = 0;
  1253.         return(fTrue);
  1254.  
  1255.     case STF_REINITDIALOG:
  1256.         SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0, MAKELONG(256, 256));
  1257.         SetFocus(GetDlgItem(hdlg, IDC_EDIT));
  1258.         return(fTrue);
  1259.  
  1260.     case STF_ACTIVATEAPP:
  1261.         return(fTrue);
  1262.  
  1263.     case WM_COMMAND:
  1264.         switch(wParam)
  1265.             {
  1266.         case IDC_EDIT:
  1267.             if (HIWORD(lParam) == EN_SETFOCUS)
  1268.                 SendDlgItemMessage(hdlg, IDC_EDIT, EM_SETSEL, 0,
  1269.                         MAKELONG(wSelStart1, wSelEnd1));
  1270.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  1271.                 {
  1272.                 LONG l = SendDlgItemMessage(hdlg, IDC_EDIT, EM_GETSEL, 0, 0L);
  1273.  
  1274.                 wSelStart1 = LOWORD(l);
  1275.                 wSelEnd1   = HIWORD(l);
  1276.                 }
  1277.             break;
  1278.  
  1279.         case IDC_EDIT2:
  1280.             if (HIWORD(lParam) == EN_SETFOCUS)
  1281.                 SendDlgItemMessage(hdlg, IDC_EDIT2, EM_SETSEL, 0,
  1282.                         MAKELONG(wSelStart2, wSelEnd2));
  1283.             else if (HIWORD(lParam) == EN_KILLFOCUS)
  1284.                 {
  1285.                 LONG l = SendDlgItemMessage(hdlg, IDC_EDIT2, EM_GETSEL, 0, 0L);
  1286.  
  1287.                 wSelStart2 = LOWORD(l);
  1288.                 wSelEnd2   = HIWORD(l);
  1289.                 }
  1290.             break;
  1291.  
  1292.         case IDC_H:
  1293.             HdlgShowHelp();
  1294.             return(fTrue);
  1295.  
  1296.         case IDC_B:
  1297.         case IDC_C:
  1298.         case IDC_X:
  1299.         case IDCANCEL:
  1300.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1301.                 {
  1302.                 DestroyWindow(GetParent(hdlg));
  1303.                 return(fTrue);
  1304.                 }
  1305.  
  1306.             SendDlgItemMessage(hdlg, IDC_EDIT, (WORD)WM_GETTEXT,
  1307.                     cbNameMax + 1, (LONG)((LPSTR)rgchText));
  1308.             if (!FSetSymbolValue("NameOut", rgchText))
  1309.                 {
  1310.                 DestroyWindow(GetParent(hdlg));
  1311.                 return(fTrue);
  1312.                 }
  1313.  
  1314.             SendDlgItemMessage(hdlg, IDC_EDIT2, (WORD)WM_GETTEXT,
  1315.                     cbNameMax + 1, (LONG)((LPSTR)rgchText));
  1316.             if (!FSetSymbolValue("OrgOut", rgchText))
  1317.                 {
  1318.                 DestroyWindow(GetParent(hdlg));
  1319.                 return(fTrue);
  1320.                 }
  1321.  
  1322.             ReactivateSetupScript();
  1323.             break;
  1324.             }
  1325.         break;
  1326.         }
  1327.  
  1328.     return(fFalse);
  1329. }
  1330.  
  1331.  
  1332.  
  1333. /*
  1334. **    Purpose:
  1335. **        Confirm Info Dialog procedure for templates with one to
  1336. **        static text controls.
  1337. **
  1338. **    Controls Recognized:
  1339. **        Text       - IDC_TEXT1 to IDC_TEXT10 (sequential)
  1340. **        Pushbutton - IDC_B, IDC_C, IDC_H, IDC_X
  1341. **
  1342. **    Initialization Symbols:
  1343. **        "ConfirmTextIn" - list of up to ten string items to initialize
  1344. **            static text items (IDC_TEXT1-10).
  1345. **
  1346. **    Termination Symbols:
  1347. **        "DLGEVENT" - one of the following, depending on event:
  1348. **                event                value
  1349. **                ----------           ----------
  1350. **                IDC_B                "BACK"
  1351. **                IDC_C                "CONTINUE"
  1352. **                IDC_X                "EXIT"
  1353. **                IDCANCEL             "CANCEL"
  1354. **
  1355. **    Note:
  1356. **        Pushbutton IDC_H will open the related Help dialog, if any.
  1357. **
  1358. *****************************************************************************/
  1359. BOOL FAR PASCAL FConfirmDlgProc(HWND hdlg, WORD wMsg, WORD wParam, LONG lParam)
  1360. {
  1361.     WORD  idc;
  1362.     WORD  cItems;
  1363.     WORD  i, cb;
  1364.     char  szSymBuf[cbSymBuf];
  1365.  
  1366.     switch (wMsg)
  1367.         {
  1368.     case WM_INITDIALOG:
  1369.         cItems = UsGetListLength("ConfirmTextIn");
  1370.         idc = IDC_TEXT1;
  1371.         for (i = 1; i <= cItems; ++i)
  1372.             {
  1373.             WORD wCheck = 0;
  1374.  
  1375.             cb = CbGetListItem("ConfirmTextIn", i, szSymBuf, cbSymBuf);
  1376.             Assert(cb < cbSymBuf);
  1377.             SetDlgItemText(hdlg, idc++, szSymBuf);
  1378.             if (i >= 4
  1379.                     && i <= 6)
  1380.                 {
  1381.                 if (*szSymBuf == '\0')
  1382.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_HIDE);
  1383.                 else
  1384.                     ShowWindow(GetDlgItem(hdlg, IDC_TEXT4+i), SW_SHOWNOACTIVATE);
  1385.                 }
  1386.             }
  1387.         return(fTrue);
  1388.  
  1389.     case STF_REINITDIALOG:
  1390.     case STF_ACTIVATEAPP:
  1391.         return(fTrue);
  1392.  
  1393.     case WM_COMMAND:
  1394.         switch (wParam)
  1395.             {
  1396.         case IDC_H:
  1397.             HdlgShowHelp();
  1398.             return(fTrue);
  1399.  
  1400.         case IDC_B:
  1401.         case IDC_C:
  1402.         case IDC_X:
  1403.         case IDCANCEL:
  1404.             if (!FSetSymbolValue("DLGEVENT", SzDlgEvent(wParam)))
  1405.                 {
  1406.                 DestroyWindow(GetParent(hdlg));
  1407.                 return(fTrue);
  1408.                 }
  1409.             ReactivateSetupScript();
  1410.             break;
  1411.             }
  1412.         break;
  1413.         }
  1414.  
  1415.     return(fFalse);
  1416. }
  1417.  
  1418.  
  1419.  
  1420. /*
  1421. **    Purpose:
  1422. **        Initialization routine for DLL.
  1423. **    Arguments:
  1424. **        hInst:       handle to instance of App that required this DLL.
  1425. **        wDataSeg:    number of words in DLL's data segment.
  1426. **        wHeapSize:   number of bytes in DLL's heap.
  1427. **        lpszCmdLine: command line for App that required this DLL.
  1428. **    Returns:
  1429. **        1 always
  1430. *****************************************************************************/
  1431. int FAR PASCAL LibMain(HANDLE hInst, WORD wDataSeg, WORD wHeapSize,
  1432.         LPSTR lpszCmdLine)
  1433. {
  1434.     if (wHeapSize > 0)
  1435.         UnlockData(0);
  1436.  
  1437.     return(1);
  1438. }
  1439.  
  1440.  
  1441.  
  1442. /*
  1443. **    Purpose:
  1444. **        Windows Exit Procedure.
  1445. **    Arguments:
  1446. **        nParam: standard WEP param (ignored).
  1447. **    Returns:
  1448. **        1 always.
  1449. *****************************************************************************/
  1450. int FAR PASCAL WEP (int nParam)
  1451. {
  1452.     return(1);
  1453. }
  1454.  
  1455.  
  1456.  
  1457. /*
  1458. **    Purpose:
  1459. **        Finds the last character in a string.
  1460. **    Arguments:
  1461. **        sz: non-NULL zero terminated string to search.
  1462. **    Returns:
  1463. **        NULL for an empty string.
  1464. **        non-Null string pointer to the last valid character in sz.
  1465. *****************************************************************************/
  1466. LPSTR FAR PASCAL SzLastChar(LPSTR sz)
  1467. {
  1468.     LPSTR szCur  = (LPSTR)NULL;
  1469.     LPSTR szNext = sz;
  1470.  
  1471.     while (*szNext != '\0')
  1472.         szNext = AnsiNext((szCur = szNext));
  1473.  
  1474.     return(szCur);
  1475. }
  1476.  
  1477.  
  1478.  
  1479. /*
  1480. **    Purpose:
  1481. **        Gets the string values for the following WM_COMMAND events:
  1482. **            IDC_B, IDC_C, IDC_X, and IDCANCEL.
  1483. **    Arguments:
  1484. **        wParam: event parameter value
  1485. **    Returns:
  1486. **        Pointer to string value constant, NULL if unknown event.
  1487. *****************************************************************************/
  1488. LPSTR FAR PASCAL SzDlgEvent(WORD wParam)
  1489. {
  1490.     LPSTR szEvent;
  1491.  
  1492.     switch(wParam)
  1493.         {
  1494.     case IDC_B:
  1495.         szEvent = "BACK";
  1496.         break;
  1497.     case IDC_C:
  1498.         szEvent = "CONTINUE";
  1499.         break;
  1500.     case IDC_X:
  1501.         szEvent = "EXIT";
  1502.         break;
  1503.     case IDC_T:
  1504.         szEvent = "TEST";
  1505.         break;
  1506.     case IDC_I:
  1507.         szEvent = "INSTALL";
  1508.         break;
  1509.     case IDC_Y:
  1510.         szEvent = "YES";
  1511.         break;
  1512.     case IDC_N:
  1513.         szEvent = "NO";
  1514.         break;
  1515.     case IDCANCEL:
  1516.         szEvent = "CANCEL";
  1517.         break;
  1518.     default:
  1519.         szEvent = NULL;
  1520.         break;
  1521.         }
  1522.  
  1523.     return(szEvent);
  1524. }
  1525.  
  1526.  
  1527.  
  1528. /*
  1529. **    Purpose:
  1530. **        Converts an ASCII string representing a positive value
  1531. **        into an integer.
  1532. **    Arguments:
  1533. **        sz: non-NULL zero terminated string to convert.
  1534. **    Returns:
  1535. **        Integer represented by the string.
  1536. *****************************************************************************/
  1537. int FAR PASCAL AsciiToInt(LPSTR sz)
  1538. {
  1539.     int i = 0;
  1540.  
  1541.     while (*sz == ' ' || *sz == '\t')
  1542.         sz++;
  1543.  
  1544.     while (isdigit(*sz))
  1545.         i = (i * 10) + *sz++ - '0';
  1546.  
  1547.     return(i);
  1548. }
  1549.  
  1550.  
  1551.  
  1552. /*
  1553. **    Purpose:
  1554. **        Converts an positive integer (< 100) into a string
  1555. **        representing its value.
  1556. **    Arguments:
  1557. **        i:  integer to convert (positive and < 100).
  1558. **        sz: buffer to hold converted string (at least 3 bytes).
  1559. **    Returns:
  1560. **        sz.
  1561. *****************************************************************************/
  1562. LPSTR FAR PASCAL IntToAscii(int i, LPSTR sz)
  1563. {
  1564.     LPSTR szSav = sz;
  1565.  
  1566.     if (i >= 100
  1567.             || i < 0)
  1568.         Assert(fFalse);
  1569.  
  1570.     if (i >= 10)
  1571.         {
  1572.         *sz++ = (char)('0' + (i / 10));
  1573.         i %= 10;
  1574.         }
  1575.     *sz++ = (char)('0' + i);
  1576.     *sz = '\0';
  1577.  
  1578.     return(szSav);
  1579. }
  1580.